<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::redirect('/', '/h5/topics/index.html');

Route::any('wechat', '\App\Http\Controllers\WeChatController@serve');
Route::get('wechat/getMenus', '\App\Http\Controllers\WeChatController@getMenus');
Route::post('wechat/createMenus', '\App\Http\Controllers\WeChatController@createMenus');

Route::get('qr_codes/{short_code}', '\App\Http\Controllers\Api\QrCodesController@show');

Route::group(['namespace' => 'App\Http\Controllers'], function() {

    Route::get('hermes', 'PagesController@hermes')->name('pages.hermes');
    Route::get('clickhouse_tab', 'PagesController@clickhouseTab')->name('pages.clickhouse_tab');

    Route::get('payment_view', 'PaymentController@payView')->name('payment.pay_view');
    Route::get('payment/{order_id}/alipay', 'PaymentController@payByAlipay')->name('payment.alipay');
    Route::get('payment/alipay/return', 'PaymentController@alipayReturn')->name('payment.alipay.return');
    Route::post('payment/alipay/notify', 'PaymentController@alipayNotify')->name('payment.alipay.notify');
    Route::get('payment/{order_id}/wechat', 'PaymentController@payByWechat')->name('payment.wechat'); // 微信支付
    Route::post('payment/wechat/notify', 'PaymentController@wechatNotify')->name('payment.wechat.notify'); // 微信支付回调

    Route::group(['middleware' => ['web', 'wechat.oauth']], function () {
        Route::get('/get_wechat_user', function () {
            return redirect()->back();
        });
    });
    Route::get('wechat/user', function () {
        $user = session('wechat.oauth_user.default'); // 拿到授权用户资料
        return response()->json($user);
    });
});
